<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Login extends CI_Controller {
    function __construct(){
        //构造函数
        parent::__construct();
        $this->load->helper(array('form', 'url'));
    }
    
    public function index()
    {
        //默认初始化函数
        //--初始化页面的数据--
        
        $this->load->view('header_v');
        $this->load->view('login/login_main_v');
        $this->load->view('footer_v');
    }
    
    //登录验证函数
    public function do_login()
    {
        $data['name']= $this->input->post('name');
        $data['pw']= $this->input->post('pw');
        //连接数据库
        $this->load->database();
        $query = $this->db->query("SELECT * FROM `user` WHERE `name`='".$data['name']."' and `password`='".$data['pw']."'");
        if ($query->num_rows() > 0)
        {   
            echo "登录成功";
        }else{
            echo "输入有误,请重新输入!";
        }
        $this->load->view('loginseccess_view',$data);//redirect()
        
    }
    
}